#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "zlib.h"

#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
#  include <fcntl.h>
#  include <io.h>
#  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
#  define SET_BINARY_MODE(file)
#endif

/* Tamanho do buffer usado para passar dados para as rotinas */
#define CHUNK 16384

int main(void)
{
	int ret, orig_a_size, orig_b_size, i, a[5];
	unsigned char b[CHUNK];
	unsigned have; /*have is the amount of data returned from deflate()*/
	z_stream strm; /*strm structure is used to pass information to and from the zlib routines*/
	unsigned char in[CHUNK];  /*in is the input buffer for deflate().*/
	unsigned char out[CHUNK];  /*out is the output buffer for deflate().*/

	for(i=0; i<5; ++i)
		a[i] = 1;
	
	for(i=0; i<10; ++i)
		b[i] = '1';
		
	orig_a_size = sizeof(a);
	orig_b_size = sizeof(b);
	
	printf("original size of a: %d\n", orig_a_size);
	printf("original size of b: %d\n", orig_b_size);	

	
	/* allocate deflate state */
	strm.zalloc = Z_NULL;
	strm.zfree = Z_NULL;
	strm.opaque = Z_NULL;
	ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
	if (ret != Z_OK)
	return ret;

    	strm.avail_in = orig_b_size;

	strm.next_in = b;

	strm.avail_out = CHUNK;
	strm.next_out = out;

	ret = deflate(&strm, Z_NO_FLUSH);    /* no bad return value */
	assert(ret != Z_STREAM_ERROR);  /* state not clobbered */

	have = CHUNK - strm.avail_out; /* how much output deflate() provided on the last call: (space provided before the call) - (output space 																available after the call) */
	printf("\nhave: %d\n", have);

	/* clean up and return */
	(void)deflateEnd(&strm);
	
	return ret;
}
